class Vue {
  constructor(option){
    this.$option = option || {};
    this.$data = option.data;
    this.$el = typeof option.el === 'string' ? document.querySelector(option.el) : option.el
    this._proxyData(this.$data);
    new Observer(this.$data)
    new Complie(this)
  }

  _proxyData(data){
    const keys = Object.keys(data);
    keys.forEach(key => {
      const dep = new Dep()
      Object.defineProperty(this, key, {
        get(){
          dep.addSub(Dep.target)
          return data[key]
        },
        set(newval){
          if(newval !== data[key]){
            data[key] = newval;
            dep.notify()
          }
        }
      })
    })
  }
}